<template>
  <div class="main main_bg">
    <gltitle :titleSize="titleSize" :is_mt="is_mt" v-if="!$store.state.isApp"></gltitle>
    <div class="container">
      <div class="list">
          <div class="it" v-for="(item,k) in datainfo.messageDetailVos" :key="k" @click="ck(item.sn,item.status,item.id,item.nextRankId,item)">
            <div class="tit db"><div class="flex">{{item.title}}</div>
              <span style="font-size: .2rem;color:#999;" >{{item.createTime}}</span></div>
            <div class="db">
              <div class="ico" v-if="item.thumbnail !== null"><img v-lazy="item.thumbnail" alt=""></div>
              <div class="flex line_2x">
                {{item.context}}
              </div>
            </div>
          </div>
      </div>
    </div>


  </div>
</template>
<script>

  export default {
    data(){
      return {
        titleSize:'',
        is_mt:true,
        datainfo:[]
      }
    },


    mounted() {
      this.getinfo()

    },
    methods: {
      getinfo(){
        this.$post(this.URL.member.messageView, {
          messageGroupId:this.$route.query.id,
          messageTypeName:this.$route.query.name,
          messageType:this.$route.query.type
        }).then((res) => {
          if (res.code == 0) {
            this.datainfo = res.data
            this.titleSize = this.$route.query.name + this.$t('member.list') + '(' + res.data.stationMessageCount + ')'
          } else {
            this.$toast(res.message);
          }
        });
      },
      ck(sn,status,id,nextRankId,el){
        //会员消息
        if(this.$route.query.type === 'MEMBER_MESSAGE'){
          this.$router.push({ path: "/member/upgrade", query: {
              level:this.$store.state.userData.level + 1
            } });
        }
        if(sn === undefined){
          return
        }
        //交易物流消息
        if(this.$route.query.type === 'TRANSACTION_DELIVERY'){
          //己发货
          if(status === 'SHIPPED'){
            this.$router.push({ path: "/order/detail_seller_ship_ok", query: {
              id:id
              } });
          }
          //待付款
          if(status === 'PENDING_PAYMENT'){
            this.$router.push({ path: "/order/detail_buyer_pay", query: {
              id : id
            } });
          }
          //己取消
          if(status === 'CANCELED'){
            this.$router.push({ path: "/order/detail_pay_ok", query: {
              id: id
            } });
          }
          //待发货
          if(status === 'PENDING_SHIPMENT'){
            this.$router.push({ path: "/order/detail_seller_ship", query: {
              id: id
            } });
          }
          //己发货
          if(status === 'RECEIVED'){
            this.$router.push({ path: "/order/detail_seller_ship_ok", query: {
              id:id
              } });
          }


        }
        //钱包消息
        if(this.$route.query.type === 'WALLET_MESSAGE'){
          if('INVOICE' == el.extendType){
            this.$router.push({ path: "/receipt/record"});
          } else {
            this.$router.push({ path: "/player_center/wallet"});
          }
        }

        //公告消息
        if(this.$route.query.type === 'SYSTEM_ANNOUNCEMENT'){
          if(el.extendType == null){
            this.$router.push({
              path: "/member/sys_message_view",
              query: {
                cont: el.context,
                time:el.createTime,
                title:el.title
              }
            });
          }
          if(el.extendType == 'RICH_TEXT')
            this.$router.push({
              path: "/member/sys_message_view",
              query: {
                cont: el.richTextContent,
                time:el.beginDate,
                title:el.title
              }
            });
          if(el.extendType == 'PRODUCT') {
            this.$router.push({
              path: "/shop/detail",
              query: {
                id: el.extendValue,
              }
            });
          }
          if(el.extendType == 'CATEGORY'){
            this.$router.push({
              path: "/shop/index",
              query: {
                id: el.extendValue,
              }
            });
          }
          if(el.extendType == 'NON'){
            if(el.url == null){
              return
            }
            window.location.href = el.url;
          }
        }




      }

    },


  }

</script>


<style lang="less" scoped>
  #app {
    .list {
      .it {
        background: #ffffff;
        border-radius: .08rem;
        box-shadow: 0px .04rem .28rem 0px rgba(53,73,93,0.07);
        padding: .2rem;
        margin-top: .2rem;

        .ico {
          width: 1.2rem;
          height: 1.2rem;
          overflow: hidden;
          margin-right: .1rem;
        }
        .flex {
          font-size: .26rem;
          font-weight: 400;
          color: #666666;
          line-height: .36rem;
        }
        .tit {
          line-height: .4rem;
          .flex {
            font-size: .28rem;
            font-weight: 400;
            color: #333333;
          }
        }
      }
    }
  }
</style>
